package top.ezzz.db;

import cn.hutool.core.util.StrUtil;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import top.ezzz.config.DbConfig;

import java.io.Serializable;

/**
 * (SystemInfo)实体类
 *
 * @author makejava
 * @since 2025-09-19 15:54:24
 */
@Slf4j
@Data
public class DbSystemInfo implements Serializable {
    private static final long serialVersionUID = 264778426690089107L;

    private Integer id;

    private String cpu;

    private String memory;

    private String os;

    private String networks;

    private String disks;


    public Object sink() {
        int insert = 0;
        try {
            Db db = DbConfig.getDb();
            String simpleName = this.getClass().getSimpleName();
            Entity entity = new Entity()
                    .setTableName(StrUtil.toUnderlineCase(simpleName))
                    .parseBean(this);
            insert = db.insert(entity);
            log.info("插入数据：{}", insert);
            return insert;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return insert;
    }
}

